[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <section class="book_son_right clearfix" v-if="newsDetail != ''">
  13. <div class="book_detail_box clearfix">
  14. <div class="book_detail_img_box">
  15. <img class="book_detail_img" :src="newsDetail.img_url" alt="" v-if="newsDetail.img_url">
  16. </div>
  17. <div class="book_detail_right clearfix">
  18. <h4 class="book_detail_right_h4">{{ newsDetail.title }}</h4>
  19. <div class="book_detail_right_title">现售价:</div>
  20. <div class="book_detail_price_box clearfix">
  21. <div class="book_detail_price_box_in clearfix">
  22. <span class="book_detail_price_red">¥</span>
  23. <span class="book_detail_price_num"
  24. v-if="newsDetail.price == '' || newsDetail.price != 0">
  25. {{ newsDetail.price }}
  26. </span>
  27. </div>
  28. <span class="book_detail_price_text">市场价:</span>
  29. <span class="book_detail_price_delete"
  30. v-if="newsDetail.market_price == '' || newsDetail.market_price != 0">
  31. {{ newsDetail.market_price }}
  32. </span>
  33. </div>
  34. <div class="book_detail_right_ul clearfix">
  35. <div class="book_detail_right_li clearfix">
  36. <label class="book_detail_right_li_label">页数:</label>
  37. <span class="book_detail_right_li_text"
  38. v-if="newsDetail.page == '' || newsDetail.page != 0">
  39. {{ newsDetail.page }}
  40. </span>
  41. </div>
  42. <div class="book_detail_right_li clearfix">
  43. <label class="book_detail_right_li_label">开本:</label>
  44. <span class="book_detail_right_li_text" v-if="newsDetail.format">
  45. {{ newsDetail.format }}
  46. </span>
  47. </div>
  48. <div class="book_detail_right_li clearfix">
  49. <label class="book_detail_right_li_label">纸张:</label>
  50. <span class="book_detail_right_li_text" v-if="newsDetail.paper">
  51. {{ newsDetail.paper }}
  52. </span>
  53. </div>
  54. <div class="book_detail_right_li clearfix">
  55. <label class="book_detail_right_li_label">包装:</label>
  56. <span class="book_detail_right_li_text" v-if="newsDetail.package">
  57. {{ newsDetail.package }}
  58. </span>
  59. </div>
  60. <div class="book_detail_right_li clearfix">
  61. <label class="book_detail_right_li_label">出版社:</label>
  62. <span class="book_detail_right_li_text" v-if="newsDetail.publishing_house">
  63. {{ newsDetail.publishing_house }}
  64. </span>
  65. </div>
  66. <div class="book_detail_right_li clearfix">
  67. <label class="book_detail_right_li_label">出版时间:</label>
  68. <span class="book_detail_right_li_text" v-if="newsDetail.publish_time">
  69. {{ getTime(newsDetail.publish_time, 'year', 1) }}
  70. </span>
  71. </div>
  72. <div class="book_detail_right_li clearfix">
  73. <label class="book_detail_right_li_label">ISBN:</label>
  74. <span class="book_detail_right_li_text" v-if="newsDetail.ISBN">
  75. {{ newsDetail.ISBN }}
  76. </span>
  77. </div>
  78. <div class="book_detail_right_li clearfix">
  79. <label class="book_detail_right_li_label">国内统一刊号CN:</label>
  80. <span class="book_detail_right_li_text" v-if="newsDetail.CN">
  81. {{ newsDetail.CN }}
  82. </span>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="book_detail_head_box clearfix">
  88. <div class="book_detail_head_left">
  89. <a class="book_detail_head_a book_detail_head_only" href="" title="">内容简介</a>
  90. </div>
  91. </div>
  92. <!-- 内容简介 -->
  93. <article class="book_detail_article" v-html="newsDetail.detail"></article>
  94. <!-- 内容简介 -->
  95. </section>
  96. <!-- 免责声明: -->
  97. <!-- v-if="newsDetail.copyfrom != '本网'" -->
  98. <div class="disclaimer" v-if="newsDetail.source != '本网'">
  99. <p>原文链接:{{ newsDetail.source_url }}</p>
  100. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  101. </div>
  102. </div>
  103. <div class="innerRight">
  104. <div class="rightMenuTitle">
  105. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  106. </div>
  107. <ul>
  108. <li v-for="(item, index) in bottomMenu" :key="index">
  109. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  110. v-if="item.category_id == pageId" class="active">
  111. {{ item.alias }}
  112. </NuxtLink>
  113. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  114. v-else-if="item.category_id != pageId">
  115. {{ item.alias }}
  116. </NuxtLink>
  117. </li>
  118. </ul>
  119. </div>
  120. <div style="clear: both;"></div>
  121. </div>
  122. </div>
  123. <!-- 广告二 -->
  124. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  125. <!-- 页面底部 -->
  126. <HomeFoot1></HomeFoot1>
  127. </template>
  128. <script setup>
  129. //1.页面依赖 start ---------------------------------------->
  130. import { ref, onMounted } from 'vue';
  131. //获得跳转过来的id
  132. const route = useRoute();
  133. //获得当前的完整路径
  134. const fullPath = route.path;
  135. //拆分,取出来中间这一段,然后提取数字部分
  136. const segments = fullPath.split('/');
  137. const targetSegment = segments[2];
  138. const targetSegment1 = segments[1];
  139. //const numberPart = targetSegment.match(/\d+$/)?.[0];
  140. let articleId;
  141. let pageId;
  142. let routeId
  143. let activeId = parseInt(route.params.id);
  144. console.log('activeId', activeId);
  145. //通过导航路径反向查询导航id
  146. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  147. method: 'GET',
  148. query: {
  149. 'pinyin': targetSegment,
  150. },
  151. });
  152. if (getRouteId.code == 200) {
  153. articleId = getRouteId.data.id;
  154. pageId = getRouteId.data.category_id;
  155. } else {
  156. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  157. console.log("错误位置:通过url路径查询导航池id")
  158. console.log("后端错误反馈:", getRouteId.message)
  159. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  160. }
  161. //通过导航路径反向查询导航id
  162. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  163. method: 'GET',
  164. query: {
  165. 'pinyin': targetSegment1,
  166. },
  167. });
  168. if (getRouteId1.code == 200) {
  169. routeId = getRouteId1.data.category_id;
  170. } else {
  171. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  172. console.log("错误位置:通过url路径查询导航池id")
  173. console.log("后端错误反馈:", getRouteId1.message)
  174. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  175. }
  176. //面包屑导航
  177. const parent_name = ref("");
  178. const parent_id = ref("");
  179. const parent_pinyin = ref("");
  180. let getParentNav = async () => {
  181. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  182. method: 'GET',
  183. query: {
  184. 'catid': routeId,
  185. },
  186. });
  187. if (listData.code == 200) {
  188. parent_name.value = listData.data.alias;
  189. parent_id.value = listData.data.parent_id;
  190. parent_pinyin.value = listData.data.aLIas_pinyin;
  191. } else {
  192. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  193. console.log("错误位置:获取面包屑导航")
  194. console.log("后端错误反馈:", listData.message)
  195. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  196. }
  197. }
  198. //获得父级栏目详情
  199. getParentNav();
  200. //1.页面依赖 end ---------------------------------------->
  201. //2.页面数据 start ---------------------------------------->
  202. //广告列表
  203. let adImg1 = ref([]);
  204. let adImg2 = ref([]);
  205. onMounted(async () => {
  206. //从客户端获取行政职能部门 加快打开速度
  207. const { $webUrl, $CwebUrl } = useNuxtApp();
  208. //广告1
  209. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_detail_0001`
  210. const responseAd1 = await fetch(url, {
  211. headers: {
  212. 'Content-Type': 'application/json',
  213. 'Userurl': $CwebUrl,
  214. 'Origin': $CwebUrl
  215. }
  216. });
  217. const resultAd1 = await responseAd1.json();
  218. adImg1.value = resultAd1.data[0];
  219. //广告2
  220. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snzxw_detail_0002`
  221. const responseAd2 = await fetch(url2, {
  222. headers: {
  223. 'Content-Type': 'application/json',
  224. 'Userurl': $CwebUrl,
  225. 'Origin': $CwebUrl
  226. }
  227. });
  228. const resultAd2 = await responseAd2.json();
  229. adImg2.value = resultAd2.data[0];
  230. })
  231. //获取页面信息
  232. const newsDetail = ref({})
  233. const bottomMenu = ref([]);
  234. async function getPageMenu() {
  235. const mkdata = await requestDataPromise('/web/getWebsiteBookInfo', {
  236. method: 'GET',
  237. query: {
  238. 'id': activeId,
  239. },
  240. });
  241. bottomMenu.value = mkdata.data.category;
  242. newsDetail.value = mkdata.data.books;
  243. }
  244. getPageMenu();
  245. //2.页面数据 end ---------------------------------------->
  246. //4.设置seo信息 start---------------------------------------->
  247. //4.1 设置seo信息
  248. const setData = await requestDataPromise('/web/getWebsiteFootInfo', {
  249. method: 'GET',
  250. query: {},
  251. });
  252. let seoTitle = setData.data.website_head.title;
  253. let seoDescription = setData.data.website_head.description;
  254. let seoKeywords = setData.data.website_head.keywords;
  255. let seoSuffix = setData.data.website_head.suffix;
  256. let seoName = setData.data.website_head.website_name;
  257. useSeoMeta({
  258. title: seoTitle + "_" + seoSuffix,
  259. meta: [
  260. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  261. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  262. ]
  263. });
  264. //4.设置seo信息 end---------------------------------------->
  265. </script>
  266. <style lang="less" scoped>
  267. @import '@/assets/css/shukanDetail.less';
  268. </style>